package com.zhongketech.sunflower.transport;

import java.util.ArrayList;

import com.zhongketech.sunflower.MyApplication;
import com.zhongketech.sunflower.MyToast;
import com.zhongketech.sunflower.R;
import com.zhongketech.sunflower.transport.im.ZKSocket;
import com.zhongketech.sunflower.transport.model.Authorizations;
import com.zhongketech.sunflower.transport.model.User;

import android.app.Activity;
import android.os.Bundle;
import android.os.Looper;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class MainActivity extends Activity{


	private ListView myList;  
	private ArrayList<String> list=new ArrayList<String>();  
	ArrayAdapter<String> adapter = null;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.transport_main);
		myList=(ListView)findViewById(R.id.listView1);  
		adapter = new ArrayAdapter<String>(this,android.R.layout.simple_expandable_list_item_1,getData());  
		myList.setAdapter(adapter); 
		findViewById(R.id.button1).setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				startTcp();
			}
		});
		
		MyToast.getInstance();
	}


	private ArrayList<String> getData()  
	{  
		list.add("aaa");  
		list.add("bbb");  
		list.add("ccc");  
		list.add("ddd");  
		return list;  
	}  

	private void startTcp()
	{
		Thread t = new Thread(){
			@Override
			public void run() {
				// TODO Auto-generated method stub
				super.run();
				Looper.prepare();
				//String id, String visible_id, String role, 
				//String phone, String password, String gender, String name,
				//String birthday, String avatar_url
//				User user = new User(MyApplication.getInstance().getId(),"44861761","student",
//						"18688708768","1234","male","kemy","1980-01-01T00:00:00Z",null);
//				Authorizations az = new Action().authorizations();
//				if(null != az)
//				{
//					ZKSocket.getInstance().handshake(az.getId(), az.getSession_token());
//				}
//				else
//				{
//					MyToast.getInstance().show("登录失败");
//				}
				
//				ZKSocket.getInstance("182.92.193.118",3579).handshake("c742913b95671625a4d05791a5834ea8", "qau89qissdird12l3nkqkmhp46");
			}
		};
		
		t.start();
	}
}
